import { defHttp } from '/@/utils/http/axios';
import { RoleSearchModel, RoleVOModel } from './model/roleModel';
import { BasicDelModel } from '../model/baseModel';

enum Api {
  BaseApi = '/sys/role',
}

/**
 * @description: 获取角色列表数据
 */
export const getRolePageApi = (data: RoleSearchModel) => {
  return defHttp.post({ url: Api.BaseApi + '/page', data });
};

/**
 * @description: 获取角色集合数据
 */
export const getRoleListApi = (data?: RoleSearchModel) => {
  return defHttp.post({ url: Api.BaseApi + '/list', data });
};

/**
 * @description: 查询角色详细信息
 */
export const getRoleInfoApi = (roleId: string) => {
  const data: RoleVOModel = {
    roleId: roleId
  };
  return defHttp.post({ url: Api.BaseApi + '/detail', data });
};

/**
 * @description: 新增角色
 */
export const saveRoleApi = (params: object) => {
  return defHttp.post({ url: Api.BaseApi + '/add', params });
};

/**
 * @description: 修改角色
 */
export const updateRoleApi = (params: object) => {
  return defHttp.post({ url: Api.BaseApi + '/edit', params });
};

/**
 * @description: 删除角色
 */
export const delRoleApi = (ids: string[]) => {
  const data: BasicDelModel = {
    ids: ids
  };
  return defHttp.post({ url: Api.BaseApi + '/delete', data });
};
